package com.wolfstreet.wsonline.util;

import android.content.Context;
import android.graphics.Bitmap;
import android.widget.ImageView;

import com.wolfstreet.wsonline.WSOApplication;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;

public class ImageHelper {

	/**
	 * 显示网络图片
	 * 
	 * @param context
	 * @param imageView
	 * @param url
	 */
	public static void showImage(Context context, ImageView imageView,
			String uri) {
		DisplayImageOptions options = new DisplayImageOptions.Builder()
				// .showStubImage(R.drawable.default_cover)
				// .showImageForEmptyUri(R.drawable.default_cover)
				// .showImageOnFail(R.drawable.default_cover)
				.cacheInMemory(true).cacheOnDisc(true)
				.imageScaleType(ImageScaleType.NONE)
				.bitmapConfig(Bitmap.Config.RGB_565)// 设置为RGB565比起默认的ARGB_8888要节省大量的内存
				.delayBeforeLoading(100)// 载入图片前稍做延时可以提高整体滑动的流畅度
				.build();

		WSOApplication.getInstance().getImageHelper()
				.displayImage(uri, imageView, options);
	}

	public static void showRoundImage(Context context, ImageView imageView,
			String uri) {
		DisplayImageOptions options = new DisplayImageOptions.Builder()
				.cacheInMemory(true).cacheOnDisc(true)
				.imageScaleType(ImageScaleType.NONE)
				.bitmapConfig(Bitmap.Config.RGB_565)// 设置为RGB565比起默认的ARGB_8888要节省大量的内存
				.delayBeforeLoading(100)// 载入图片前稍做延时可以提高整体滑动的流畅度
				.displayer(new RoundedBitmapDisplayer(1000000)).build();

		WSOApplication.getInstance().getImageHelper()
				.displayImage(uri, imageView, options);
	}

}
